﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DotNet.Business;
using DotNet.Common;

public partial class rawMaterialList : System.Web.UI.Page
{
    #region 变量
    Tab_RawMaterialBll tab_RawMaterialBll = new Tab_RawMaterialBll();
    Tab_RawMaterialClassBll tab_RawMaterialClassBll = new Tab_RawMaterialClassBll();
    int _currentIndex = 1;
    int _pageSize = 12;
    int _classID = 0;
    public string _className = "";
    #endregion

    #region 页面加载
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["i"] != null)
        {
            this._currentIndex = Convert.ToInt32(Request.QueryString["i"]);
        }
        if (Request.QueryString["c"] != null)
        {
            this._classID = Convert.ToInt32(Request.QueryString["c"]);
        }
        //绑定材料类别
        this.bindRawMaterialClass();
        //绑定材料
        this.bindRawMaterial();

    }
    #endregion

    #region 绑定材料类别
    /// <summary>
    /// 绑定材料类别
    /// </summary>
    private void bindRawMaterialClass() 
    {
        Tab_RawMaterialClass tab_RawMaterialsClass = tab_RawMaterialClassBll.GetModel(this._classID);
        this._className =">"+tab_RawMaterialsClass.rawMaterialClassName;
    }
    #endregion

    #region 绑定材料
    /// <summary>
    /// 绑定材料
    /// </summary>
    private void bindRawMaterial() 
    {
        this.Rep_RawMaterial.DataSource = this.tab_RawMaterialBll.pageForRawMaterial(this._currentIndex, this._pageSize, this._classID);
        this.Rep_RawMaterial.DataBind();
    }    
    #endregion

    #region 分页按钮
    /// <summary>
    /// 分页按钮
    /// </summary>
    public void htmlPaging()
    {
        string str = null;
        int count = 0;
        count = tab_RawMaterialBll.getRecordCount(this._classID);
        int pcount = count % this._pageSize == 0 ? count / this._pageSize : count / this._pageSize + 1;
        str = "页次：" + this._currentIndex + "/" + pcount + "  每页" + this._pageSize + " 总收录数据" + count + "条";
        str += HtmlControls.pagIng(this._currentIndex, pcount, "rawMaterialList.aspx?i", "pageaa", "pagecurrent");
        Response.Write(str);
    }
    #endregion
}
